package max.ta.math;

public final class SeriesMath {

    public static double[] scale(double[] points) {
	double factor = min(points) / max(points);
	return scale(points, factor);
    }

    public static double[] scale(double[] points, double factor) {
	double[] results = new double[points.length];
	for (int i = 0; i < points.length; i++) {
	    results[i] = points[i] * factor;
	}
	return results;
    }

    public static double max(double[] points) {
	double max = Double.MIN_VALUE;
	for (int i = 0; i < points.length; i++) {
	    if (max < points[i]) {
		max = points[i];
	    }
	}
	return max;
    }

    public static double min(double[] points) {
	double min = Double.MAX_VALUE;
	for (int i = 0; i < points.length; i++) {
	    if (min > points[i]) {
		min = points[i];
	    }
	}
	return min;
    }

    public static double[] log(double[] points) {
	double[] results = new double[points.length];
	for (int i = 0; i < points.length; i++) {
	    results[i] = Math.log(points[i]);
	}
	return results;
    }
}
